﻿
Imports System.Data
Imports Cls_Common
Partial Class Control_Menu_KhachSanMenu
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init

        If Session("UserName") Is Nothing Or Session("HotelId") Is Nothing Then
            Response.Redirect("~/Login.aspx")
        End If

    End Sub
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then

            Dim lstNode As New DataSet
            Dim _UserTypeId As Integer = Session("UserTypeId")
            If _UserTypeId = 2 Then
                lstNode.ReadXml(MapPath("../../xml/HeaderKhachSanMenu.xml"))
                With rptMenu
                    .DataSource = lstNode.Tables("Node")
                    .DataBind()
                End With
            ElseIf _UserTypeId = 3 Then
                lstNode.ReadXml(MapPath("../../xml/HeaderKhachSanNhapFile.xml"))
                With rptMenu
                    .DataSource = lstNode.Tables("Node")
                    .DataBind()
                End With
            End If


        End If
    End Sub
    Protected Sub rptMenu_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptMenu.ItemDataBound
        Dim hplTitle As HyperLink
        hplTitle = e.Item.FindControl("hplTitle")

        'hplTitle.NavigateUrl = DomainURL & "Page/Default.aspx?DepID=" & e.Item.DataItem("DepID").ToString
        hplTitle.NavigateUrl = MainDomain & e.Item.DataItem("URL").ToString
        If Request.Url.ToString.Contains(e.Item.DataItem("URL")) Then
            hplTitle.Text = "<span class=""menu-left""></span><span class=""menu-mid active"">" & e.Item.DataItem("Title") & "</span><span class=""menu-right""></span>"
        Else
            hplTitle.Text = "<span class=""menu-left""></span><span class=""menu-mid"">" & e.Item.DataItem("Title") & "</span><span class=""menu-right""></span>"
        End If



    End Sub

End Class
